package gxb.test14;

import java.util.Random;

//验证码
public class Verification {
    public static void main(String[] args) {
        String verificationCode = getCode();
        System.out.println("验证码：" + verificationCode);
    }

    public static String getCode() {
        Random random = new Random();
        StringBuilder code = new StringBuilder();

        // 生成前四位随机字母
        for (int i = 0; i < 4; i++) {
            char c = (char) (random.nextInt(26) + 'A');
            code.append(c);
        }

        // 生成最后一位随机数字
        int digit = random.nextInt(10);
        code.append(digit);

        return code.toString();
    }
}
